package com.nondo.dean.dealer.service;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.nondo.dean.common.tool.AliyunOssTool;
import com.nondo.dean.dealer.common.Constant;
import com.nondo.dean.dealer.domain.ActivityGoods;
import com.nondo.dean.dealer.domain.ActivityGoodsExample;
import com.nondo.dean.dealer.mapper.ActivityGoodsMapper;

/**
 * @author xiaofan
 * @Description: 活动商品业务管理类
 * @throws
 * @date 2018-05-0913:55
 * @Version 0.1
 */
@Component
public class ActivityGoodsService {

    @Autowired
    private ActivityGoodsMapper activityGoodsMapper;

    @Autowired
    private ProductService productService;
    
    @Autowired
    AliyunOssTool aliyunOssTool;

    public int add(ActivityGoods activityGoods){
        return activityGoodsMapper.insertSelective(activityGoods);
    }

    /**
     * 根据活动id返回参与活动的产品
     * @param activityId
     * @return
     */
    public List<ActivityGoods> getActivityGoodsList(Integer activityId){
        List<ActivityGoods> activityGoodsList = new ArrayList<ActivityGoods>();
        if (activityId == null) {
            return activityGoodsList;
        }
        ActivityGoodsExample example = new ActivityGoodsExample();
        example.createCriteria().andAcitivityIdEqualTo(activityId).andDelFlagEqualTo(ActivityGoods.DEL_FLAG_NORMAL).andStatusEqualTo(Constant.COMMODITY_STATUS_START);
        activityGoodsList = activityGoodsMapper.selectByExample(example);
        return activityGoodsList;
    }
    
}
